package com.tencent.crazypenguin.action;
import com.opensymphony.xwork2.ActionSupport;
import com.tencent.crazypenguin.bean.User;
import com.tencent.crazypenguin.config.HbmUtil;
import com.tencent.crazypenguin.config.ResultType;
import com.tencent.crazypenguin.dao.UserDao;
import com.tencent.crazypenguin.util.JsonUtil;

import net.sf.json.JSONObject;

public class userinfo extends ActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String result;
	//private String userName;
	@Override
	public String execute() throws Exception {
		JSONObject rspData = new JSONObject(); 
		
		try {
			UserDao userDao = new UserDao();		
			JSONObject authData = HbmUtil.getAuthDate();	
			long id = authData.getLong("id");
			JSONObject json;
			
			User user = userDao.findById(id, new User());
			json = JSONObject.fromObject(user);
			rspData.put("resultCode", ResultType.SUCEESS);
			rspData.put("user", json);
			result = rspData.toString();
			return "done";
		} catch (Exception e) {
			e.printStackTrace();
			rspData.put("resultCode", ResultType.EXCEPTION);
			result = rspData.toString();
			return "done";
		}
		
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	//public String getUserName()
	//{
	//	return this.userName;
	//}
	//public void setUserName(String userName)
	//{
	//	this.userName=userName;
	//}
	

}
